﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace PingPong
{
    public class Obstacle
    {
        static Random randomGenerator = new Random();

        public int PositionX { get; set; }

        public int PositionY { get; set; }

        public char CurrentSymbol { get; set; }

        public ConsoleColor Color { get; set; }

        public char[] symbol = new char[] { '%', '@', '$', '\u2588', };

        static ConsoleColor GetRandomColor()
        {
            string[] colorNames = ConsoleColor.GetNames(typeof(ConsoleColor));
            int numColors = colorNames.Length;
            string colorName = colorNames[randomGenerator.Next(2, numColors)];
            ConsoleColor color = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), colorName);
            return color;
        }

        public Obstacle(PlayGround playground)
        {
            Color = GetRandomColor();
            SetRandomChar();
            PositionX = randomGenerator.Next((playground.Width / 2) - 5, (playground.Width / 2) + 5);
            PositionY = 1;
        }

        public void MoveObstacle(PlayGround playground)
        {
            if (PositionY != playground.Height - 3)
            {
                PositionY++;
            }
        }

        public void SetRandomChar()
        {
            CurrentSymbol = symbol[randomGenerator.Next(0, 4)];
        }
    }
}
